Home

Learn Programming & Prepare for NPTEL Exams... Swayam Solver is your one-stop destination for NPTEL exam preparation.

NPTEL The Joy of Computing using Python July - 2026 | Swayam

 

The Joy of Computing using Python - July 2026

 Please scroll down for latest Programs   ðŸ‘‡ 


Code compiled and tested successfully!



Week 03 - Programming Assignment 01

Due date on 2026-08-14, 23:59 IST

Your last recorded submission was on 2026-08-14, 16:24 IST.

Q.

During a school sports meet, the finishing times (in seconds) of runners are recorded. A lower time indicates a faster runner.

(a) Accept a space-separated list of positive real numbers representing finishing times.
(b) Find the minimum finishing time.
(c) Print the fastest finishing time.

Complete Program

Python
# --- START OF SOLUTION CODE ---
times = list(map(float, input().split()))
print(min(times))
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
times = list(map(float, input().split()))
print(min(times))
# --- END OF SOLUTION CODE ---


You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

12.5 11.8 13.2

11.8
11.8\n
Presentation Error
Test Case 2

9.5 8.4 8.4 10.1

8.4
8.4\n
Presentation Error
Test Case 3

15.0

15.0
15.0\n
Presentation Error
Test Case 4

7.2 7.8 6.9

6.9
6.9\n
Presentation Error


Week 03 - Programming Assignment 02

Due date on 2026-08-14, 23:59 IST

Q.

A weather station records daily temperatures as decimal values.

(a) Accept a space-separated sequence of real numbers.
(b) Convert each temperature to its integer part.
(c) Print the sum of all converted integer values.

Complete Program

Python
# --- START OF SOLUTION CODE ---
temps = input().split()
print(sum(int(float(x)) for x in temps))
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
temps = input().split()
print(sum(int(float(x)) for x in temps))
# --- END OF SOLUTION CODE ---


You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

25.8 30.2 18.9

73
73\n
Presentation Error
Test Case 2

10.0 20.7

30
30\n
Presentation Error
Test Case 3

5.5

5
5\n
Presentation Error
Test Case 4

0.8 1.9 2.1

3
3\n
Presentation Error



Week 03 - Programming Assignment 03

Due date on 2026-08-14, 23:59 IST

Your last recorded submission was on 2026-08-14, 16:56 IST.

Q.

A courier company records package weights (in kg).

(a) Accept a space-separated list of positive real numbers.
(b) Compute the average package weight.
(c) Count how many package weights are greater than the average.


Complete Program

Python
# --- START OF SOLUTION CODE ---
weights = list(map(float, input().split()))
avg = sum(weights) / len(weights)
print(sum(1 for w in weights if w > avg))
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
weights = list(map(float, input().split()))
avg = sum(weights) / len(weights)
print(sum(1 for w in weights if w > avg))
# --- END OF SOLUTION CODE ---


You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

2.5 3.0 5.5

1
1\n
Presentation Error
Test Case 2

1.0 1.0 1.0

0
0\n
Presentation Error
Test Case 3

10.5 20.5 30.5

1
1\n
Presentation Error
Test Case 4

4.2 5.1 6.3 7.4

2
2\n
Presentation Error



Week 04 - Programming Assignment 01

Due date on 2026-08-20, 23:59 IST

Your last recorded submission was on 2026-08-19, 09:32 IST.

Q.

Modern weather stations continuously record temperature readings throughout the day. At the end of the day, the system needs to determine how much the temperature varied.

Write a Python program that:

  1. Accepts space-separated integers representing temperature readings.
  2. Finds the highest and lowest temperature recorded.
  3. Calculates and prints the temperature range, defined as the difference between the highest and lowest readings.
  4. If there is only one reading, print 0.

Complete Program

Python
# --- START OF SOLUTION CODE ---
# Read space-separated integers representing temperature readings
temperatures = list(map(int, input().split()))

# Calculate temperature range (highest - lowest)
temp_range = max(temperatures) - min(temperatures)

# Print the result
print(temp_range)
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
temperatures = list(map(int, input().split()))
temp_range = max(temperatures) - min(temperatures)
print(temp_range)
# --- END OF SOLUTION CODE ---


You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

25 30 28

5
5\n
Presentation Error
Test Case 2

18

0
0\n
Presentation Error
Test Case 3

40 35 32 38

8
8\n
Presentation Error
Test Case 4

10 10

0
0\n
Presentation Error


Week 04 - Programming Assignment 02

Due date on 2026-08-20, 23:59 IST

Your last recorded submission was on 2026-08-19, 09:36 IST.

Q.

A cybersecurity application generates numeric authentication codes. Before using a code, the software checks whether it is a prime number.

Write a Python program that:

  1. Accepts a positive integer n.
  2. Prints True if n is a prime number; otherwise, prints False.

Complete Program

Python
# --- START OF SOLUTION CODE ---
def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

n = int(input().strip())
print(is_prime(n))
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

n = int(input().strip())
print(is_prime(n))
# --- END OF SOLUTION CODE ---


You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

2

True
True\n
Presentation Error
Test Case 2

17

True
True\n
Presentation Error
Test Case 3

18

False
False\n
Presentation Error
Test Case 4

1

False
False\n
Presentation Error


Week 04 - Programming Assignment 03

Due date on 2026-08-20, 23:59 IST

Your last recorded submission was on 2026-08-19, 09:39 IST.

Q.

A shopping platform records the product IDs viewed by a customer during a browsing session. The system needs to determine whether the customer viewed any product more than once.

Write a Python program that:

  1. Accepts space-separated integers representing product IDs.
  2. Prints True if at least one product ID appears more than once.
  3. Otherwise, prints False.

Complete Program

Python
# --- START OF SOLUTION CODE ---
# Read space-separated product IDs
product_ids = input().split()

# Check if any product ID appears more than once
has_duplicates = len(product_ids) != len(set(product_ids))

# Print True if duplicates exist, otherwise False
print(has_duplicates)
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
product_ids = input().split()
has_duplicates = len(product_ids) != len(set(product_ids))
print(has_duplicates)
# --- END OF SOLUTION CODE ---


You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

1 2 3 4 5

False
False\n
Presentation Error
Test Case 2

1 2 3 3 4

True
True\n
Presentation Error
Test Case 3

1 1

True
True\n
Presentation Error
Test Case 4

1 4 7 9

False
False\n
Presentation Error



Week 05 - Programming Assignment 01

Due date on 2026-08-27, 23:59 IST

Your last recorded submission was on 2026-08-19, 11:12 IST.

Q.

A data analyst receives a sequence of integers representing values recorded by a sensor. Some values may occur multiple times.

Write a function that:

(a) Accepts a space-separated sequence of integers.
(b) Returns the number that occurs most frequently.
(c) If two or more numbers have the same highest frequency, returns the smallest number.

Complete Program

Python
# --- START OF SOLUTION CODE ---
# Read space-separated integers
nums = list(map(int, input().split()))

# Count frequency of each number
counts = {}
for num in nums:
    counts[num] = counts.get(num, 0) + 1

# Find the number with the highest frequency; if tied, pick the smallest number
result = min(counts.keys(), key=lambda x: (-counts[x], x))

# Print the result
print(result)
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
nums = list(map(int, input().split()))

counts = {}
for num in nums:
    counts[num] = counts.get(num, 0) + 1

result = min(counts.keys(), key=lambda x: (-counts[x], x))

print(result)
# --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

2 5 2 3 5 2 4 5

2
2\n
Presentation Error
Test Case 2

4 7 4 2 7 9 7

7
7\n
Presentation Error
Test Case 3

5 3 5 3 8 8

3
3\n
Presentation Error
Test Case 4

1 2 3 4 5

1
1\n
Presentation Error


Week 05 - Programming Assignment 02

Due date on 2026-08-27, 23:59 IST

Your last recorded submission was on 2026-08-19, 11:17 IST.

Q.

A system receives a sequence of integers. Some numbers may appear more than once.

Write a function that:

(a) Accepts a space-separated sequence of integers.
(b) Returns all numbers that occur more than once.
(c) The numbers should be returned in the order of their first appearance.
(d) If no number is repeated, returns -1.

Complete Program

Python
# --- START OF SOLUTION CODE ---
# Read space-separated sequence of integers
nums = list(map(int, input().split()))

# Count occurrences of each number while preserving first-appearance order
counts = {}
for num in nums:
    counts[num] = counts.get(num, 0) + 1

# Filter for numbers occurring more than once
duplicates = [num for num in counts if counts[num] > 1]

# Print result in order of first appearance, or -1 if no duplicates
if duplicates:
    print(*duplicates)
else:
    print(-1)
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
nums = list(map(int, input().split()))

counts = {}
for num in nums:
    counts[num] = counts.get(num, 0) + 1

duplicates = [num for num in counts if counts[num] > 1]

if duplicates:
    print(*duplicates)
else:
    print(-1)
# --- END OF SOLUTION CODE ---


You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

4 2 7 4 2 9 7

4 2 7
4 2 7\n
Presentation Error
Test Case 2

5 5 3 2 3 8

5 3
5 3\n
Presentation Error
Test Case 3

1 2 3 4 5

-1
-1\n
Presentation Error
Test Case 4

10 20 10 30 20 40

10 20
10 20\n
Presentation Error


Week 05 - Programming Assignment 03

Due date on 2026-08-27, 23:59 IST

Your last recorded submission was on 2026-08-19, 11:30 IST.

Q.

A sequence of integers is given. Find all numbers that occur exactly two times.

Write a function that:

(a) Accepts a space-separated sequence of integers.
(b) Returns all numbers that occur exactly two times.
(c) The numbers should be returned in increasing order.
(d) If no number occurs exactly two times, returns -1.

Complete Program

Python
# --- START OF SOLUTION CODE ---
# Read space-separated sequence of integers
nums = list(map(int, input().split()))

# Count frequency of each number
counts = {}
for num in nums:
    counts[num] = counts.get(num, 0) + 1

# Filter for numbers that occur exactly two times
exact_two = [num for num, count in counts.items() if count == 2]

# Sort the numbers in increasing order
exact_two.sort()

# Print result or -1 if no such number exists
if exact_two:
    print(*exact_two)
else:
    print(-1)
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
nums = list(map(int, input().split()))

counts = {}
for num in nums:
    counts[num] = counts.get(num, 0) + 1

exact_two = [num for num, count in counts.items() if count == 2]
exact_two.sort()

if exact_two:
    print(*exact_two)
else:
    print(-1)
# --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 3/3 Passed

Note: These tests may not be considered while scoring.

Private Test Cases

Private Test cases used for Evaluation
Status
Test Case 1
Passed
Test Case 2
Passed
Test Case 3
Passed



Week 06 - Programming Assignment 01

Due date on 2026-09-03, 23:59 IST

Your last recorded submission was on 2026-08-22, 20:33 IST.

Q.

A cybersecurity company evaluates password strength by counting the number of alphabetic characters in a password. Due to memory constraints in a secure device, the counting must be performed recursively.

Write a recursive function that:
(a) Accepts a string s as input.
(b) Returns an integer representing the number of alphabetic characters (A-Z and a-z) in the string.
(c) Does not use loops.

Complete Program

Python
def count_alpha(s):
    if not s:
        return 0
    return (1 if s[0].isalpha() else 0) + count_alpha(s[1:])

if __name__ == "__main__":
    s = input()
    print(count_alpha(s))

Code Snippet to Paste in the Editor

Python
def count_alpha(s):
    if not s:
        return 0
    return (1 if s[0].isalpha() else 0) + count_alpha(s[1:])

s = input()
print(count_alpha(s))


You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

abc123

3
3\n
Presentation Error
Test Case 2

CSE

3
3\n
Presentation Error
Test Case 3

12345

0
0\n
Presentation Error
Test Case 4

aa12

2
2\n
Presentation Error


Week 06 - Programming Assignment 02

Due date on 2026-09-03, 23:59 IST

Your last recorded submission was on 2026-08-22, 20:36 IST.

Q.

A warehouse records the boxes currently stored in its inventory as a list of box IDs. Implement a program using recursion to determine the total number of boxes in the inventory.

Write a program that:
(a) Accepts space-separated integers as input, where each integer represents a box ID.
(b) Uses recursion to count the number of boxes and displays the count as an integer.
(c) Does not use loops or the len() function.

Complete Program

Python
def count_boxes(lst):
    if not lst:
        return 0
    return 1 + count_boxes(lst[1:])

if __name__ == "__main__":
    boxes = input().split()
    print(count_boxes(boxes))

Code Snippet to Paste in the Editor

Python
def count_boxes(lst):
    if not lst:
        return 0
    return 1 + count_boxes(lst[1:])

boxes = input().split()
print(count_boxes(boxes))
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

1 2 3

3
3\n
Presentation Error
Test Case 2

7 9

2
2\n
Presentation Error
Test Case 3

10

1
1\n
Presentation Error
Test Case 4

1 5 7 9 11

5
5\n
Presentation Error


Week 06 - Programming Assignment 03

Due date on 2026-09-03, 23:59 IST

Q.

A weather station records daily temperatures as a list of values. Implement a program using recursion to determine the highest temperature recorded.

Write a program that:
(a) Accepts space-separated integers as input, where each integer represents a recorded temperature.
(b) Uses recursion to find and display the highest temperature as an integer.
(c) Does not use loops or the max() function.

Code Snippet to Paste in the Editor

Python
def find_max(lst):
    if len(lst) == 1:
        return int(lst[0])
    first = int(lst[0])
    rest_max = find_max(lst[1:])
    return first if first > rest_max else rest_max

temps = input().split()
print(find_max(temps))
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

3 1 4

4
4\n
Presentation Error
Test Case 2

10

10
10\n
Presentation Error
Test Case 3

3 7 19

19
19\n
Presentation Error
Test Case 4

5 2 8 1

8
8\n
Presentation Error


Week 07 - Programming Assignment 01

Due date on 2026-09-10, 23:59 IST

Your last recorded submission was on 2026-08-30, 08:03 IST.

Q.

Tourism applications store information about attractions using dictionaries for quick retrieval.

Write a program that accepts attraction information and an attraction name. The program should print the rating of the attraction if it exists; otherwise, print -1.

Input:

  • The first input line contains the number of attractions N.
  • The next N lines contain an attraction name followed by its rating separated by a space. Please refer to public test cases for sample.
  • The last line contains the name of the attraction to search.

Output:
Print the rating of the attraction if it exists; otherwise, print -1.

Note: Each attraction name is followed by its rating, which is a decimal number with exactly one digit after the decimal point.

Complete Program

Python
# --- START OF SOLUTION CODE ---
n = int(input().strip())
attractions = {}

for _ in range(n):
    line = input().strip()
    name, rating = line.rsplit(' ', 1)
    attractions[name] = rating

search_name = input().strip()

print(attractions.get(search_name, -1))
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
n = int(input().strip())
attractions = {}

for _ in range(n):
    line = input().strip()
    name, rating = line.rsplit(' ', 1)
    attractions[name] = rating

search_name = input().strip()

print(attractions.get(search_name, -1))
# --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

3 Museum 4.5 Park 4.2 Temple 4.8 Museum

4.5
4.5\n
Presentation Error
Test Case 2

1 Temple 4.8 Temple

4.8
4.8\n
Presentation Error
Test Case 3

4 Museum 4.5 Park 4.2 Temple 4.8 Fort 5.0 Zoo

-1
-1\n
Presentation Error
Test Case 4

3 Lake 4.1 Beach 4.7 Hill 3.9 Beach

4.7
4.7\n
Presentation Error


Week 07 - Programming Assignment 02

Due date on 2026-09-10, 23:59 IST

Your last recorded submission was on 2026-08-30, 08:07 IST.

Q.

A navigation system stores landmark names in a list.

Write a program that accepts a list of landmark names and a landmark to search. The program should use linear search to find the landmark and print its index. If the landmark is not found, print -1.

Input:

  • The first input line contains the number of landmarks N.
  • The next line contains N landmark names separated by spaces. All landmarks have single word in them. 
  • The last line contains the landmark name to search.

Output:
Print the index of the landmark if it is found; otherwise, print -1.

Complete Program

Python
# --- START OF SOLUTION CODE ---
n = int(input().strip())
landmarks = input().strip().split()
target = input().strip()

print(landmarks.index(target) if target in landmarks else -1)
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
n = int(input().strip())
landmarks = input().strip().split()
target = input().strip()

print(landmarks.index(target) if target in landmarks else -1)
# --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

5 Park Museum Temple Lake Fort Temple

2
2\n
Presentation Error
Test Case 2

3 Park Museum Fort Museum

1
1\n
Presentation Error
Test Case 3

4 Gateway Charminar Mahal Hampi Gateway

0
0\n
Presentation Error
Test Case 4

3 Mysore Golgumbaz Aihole Badami

-1
-1\n
Presentation Error


Week 07 - Programming Assignment 03

Due date on 2026-09-10, 23:59 IST

Your last recorded submission was on 2026-08-30, 08:09 IST.

Q.

A system receives a set of numbers and needs to identify the second largest number.

Write a program that accepts a set of integers and prints the second largest number. Assume that all numbers are distinct.

Input:
A single line containing space-separated integers.

Output:
Print the second largest number.

Complete Program

Python
# --- START OF SOLUTION CODE ---
numbers = list(map(int, input().split()))
numbers.sort()
print(numbers[-2])
# --- END OF SOLUTION CODE ---

Code Snippet to Paste in the Editor

Python
# --- START OF SOLUTION CODE ---
numbers = list(map(int, input().split()))
numbers.sort()
print(numbers[-2])
# --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 4/4 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

18 42 7 31 25 50

42
42\n
Presentation Error
Test Case 2

15 8 23 41 17

23
23\n
Presentation Error
Test Case 3

90 45 72 18 63 37

72
72\n
Presentation Error
Test Case 4

5 12 3 9 20

12
12\n
Presentation Error









































































No comments:

Post a Comment

Keep your comments reader friendly. Be civil and respectful. No self-promotion or spam. Stick to the topic. Questions welcome.